package com.jk.wh.controller;

import com.jk.*;
import com.jk.service.wh.MovieApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

@Controller
@RequestMapping("movie")
public class MovieController {

    @Autowired
    private MovieApi movieApi;
    //跳转首页
    @RequestMapping("homepage")
    public String homepage(){
        return "homepage/index2";
    }
    //跳转电影页面 大查询
    @RequestMapping("movieAll")
    public String jumpQueryMovieById(Integer status,Model model)
    {
        model.addAttribute("status",status);
        return "movieAll/movieAll";
    }
    //全部查询
    @GetMapping("/queryMovie")
    @ResponseBody
    public List<MovieBean> queryMovie(MovieBean movie){
        return movieApi.queryMovie(movie);
    }
    //查询正在热映的电影 -by徐卓
    @GetMapping("/getRadientMovie")
    @ResponseBody
    public List<MovieBean>  getRadientMovie(Model model)
    {
        List<MovieBean> list=  movieApi.getRadientMovie();
        model.addAttribute("list",list);
        return list;
    };
    //查询待上映的电影 -by徐卓
    @RequestMapping("/waitMovie")
    @ResponseBody
    public List<MovieBean> waitMovie(){
        return movieApi.waitMovie();
    };
    //查询最受期待电影前10 -by徐卓
    @RequestMapping("/expectMovie")
    @ResponseBody
    public List<MovieBean> expectMovie(){
        return movieApi.expectMovie();
    };
    //查询前10的高评分电影 -by徐卓
    @RequestMapping("/getScore")
    @ResponseBody
    public List<MovieBean> getScore(){
        return movieApi.getScore();
    };
    /*
    * @Author: xz
    * @Description: 查询已上映的总条数
    * @Date: 2021/5/24 9:56
    * @Param:
    * @Return:
    **/
    @RequestMapping("getMovieCount")
    @ResponseBody
    public Integer  getMovieCount(){
        return movieApi.getMovieCount();
    };
    /*
     * @Author: xz
     * @Description: 查询待上映的总条数
     * @Date: 2021/5/24 9:56
     * @Param:
     * @Return:
     **/
    @RequestMapping("getMovieCount2")
    @ResponseBody
    public Integer  getMovieCount2(){
        return movieApi.getMovieCount2();
    };




    /**
    * @Author: wh
    * @Description: 轮播图
    * @Date: 2021/5/24 17:34
    * @Param:[]
    * @Return: java.util.List<com.jk.CarouselBean>
    **/
    @RequestMapping("getCarousel")
    @ResponseBody
    public List<CarouselBean> getCarousel(){
        return movieApi.getCarousel();
    }
    /*
    * @Author: xz
    * @Description: 查询类型表
    * @Date: 2021/5/25 15:49
    * @Param:
    * @Return:
    **/
    @RequestMapping("getType")
    @ResponseBody
    public List<MovieTypeBean> getType(){
        return movieApi.getType();
    }
    /*
    * @Author: xz
    * @Description: 跳转查询电影的页面
    * @Date: 2021/5/26 10:12
    * @Param:
    * @Return:
    **/
    @RequestMapping("getMovie")
    public String getMovie(String movieName,Model model){
        model.addAttribute("movieName",movieName);
        return "getMovie/getMovie";
    }
    /*
    * @Author: xz
    * @Description: 查询条查总条数
    * @Date: 2021/5/26 11:48
    * @Param:[]
    * @Return: java.lang.Integer
    **/
    @RequestMapping("getMovieCountByStatus")
    @ResponseBody
    public Integer getMovieCountByStatus(String MovieName){
        return movieApi.getMovieCountByStatus(MovieName);
    }
    /*
    * @Author: xz
    * @Description: 查询热播电影
    * @Date: 2021/5/26 15:14
    * @Param:
    * @Return:
    **/
    @RequestMapping("queryHitTv")
    @ResponseBody
    public List<MovieBean> queryHitTv(MovieBean mm){
        return  movieApi.queryHitTv(mm);
    }
    /*
    * @Author: xz
    * @Description: 获取票房排行前五名
    * @Date: 2021/5/26 16:23
    * @Param:
    * @Return:
    **/
    @RequestMapping("getMoney")
    @ResponseBody
    public List<MovieBean> getMoney(){
        return  movieApi.getMoney();
    }
   /*
   * @Author: xz
   * @Description: 跳转影院
   * @Date: 2021/5/27 10:08
   * @Param:
   * @Return:
   **/
   @RequestMapping("cinemaAll")
    public String cinemaAll(){
       return "cinemaAll/cinemaAll";
   }
   /*
   * @Author: xz
   * @Description:查询影院
   * @Date: 2021/5/27 11:20
   * @Param:
   * @Return:
   **/
    @RequestMapping("queryCinemaAll")
    @ResponseBody
    public List<CinemaBean> queryCinemaAll(CinemaBean cc){
       return movieApi.queryCinemaAll(cc);
   }
   /*
   * @Author: xz
   * @Description: 购票选座
   * @Date: 2021/5/27 14:30
   * @Param:
   * @Return:
   **/
   @RequestMapping("buyTicket")
    public String buyTicket(Integer cinemaId,Model model){
       model.addAttribute("cinemaId",cinemaId);
       return "buyticket/buyTicket";
   }
   /*
   * @Author: xz
   * @Description: 根据id查询影院
   * @Date: 2021/5/27 15:14
   * @Param:[cinemaId]
   * @Return: com.jk.CinemaBean
   **/
   @RequestMapping("buyTicketById")
   @ResponseBody
   public CinemaBean buyTicketById(Integer cinemaId){
       return movieApi.buyTicketById(cinemaId);
   }
   /*
   * @Author: xz
   * @Description: 根据影院id查询影院对应的电影
   * @Date: 2021/5/27 21:44
   * @Param:
   * @Return:
   **/
   @RequestMapping("queryMovieAllById")
   @ResponseBody
   public List<MovieBean> queryMovieAllById(Integer cinemaId){
       return movieApi.queryMovieAllById(cinemaId);
   }
   /*
   * @Author: xz
   * @Description: 根据影院id 电影id查看排片观影时间
   * @Date: 2021/5/28 17:35
   * @Param:[cinemaId, movieId]
   * @Return: java.util.List<com.jk.MovieBean>
   **/
   @RequestMapping("getMovieCinemaById")
   @ResponseBody
   public List<MovieBean> getMovieCinemaById(Integer cinemaId,Integer movieId,String date){
        return movieApi.getMovieCinemaById(cinemaId,movieId,date);
   }
   /*
   * @Author: xz
   * @Description: 根据影院id 电影id查询影院对应的电影
   * @Date: 2021/5/28 20:56
   * @Param:[cinemaId, movieId]
   * @Return: com.jk.MovieBean
   **/
   @RequestMapping("getMovies2")
   @ResponseBody
   public MovieBean getMovies2(Integer cinemaId,Integer movieId){
       return movieApi.getMovies2(cinemaId,movieId);
   }
  /*
  * @Author: xz
  * @Description: 动态查询排片时间
  * @Date: 2021/5/30 10:28
  * @Param:
  * @Return:
  **/
  @RequestMapping("getDate")
  @ResponseBody
  public List<ProgramBean> getDate(Integer cinemaId,Integer movieId){
      return movieApi.getDate(cinemaId,movieId);
  }
  /*
  * @Author: xz
  * @Description: 获取影院
  * @Date: 2021/5/30 21:01
  * @Param:
  * @Return:
  **/
  @RequestMapping("getCinema")
  @ResponseBody
  public List<CinemaBean> getCinema(){
      return movieApi.getCinema();
  }
  /*
  * @Author: xz
  * @Description: 获取西安市的区
  * @Date: 2021/5/30 21:12
  * @Param:[]
  * @Return: java.util.List<com.jk.AddressBean>
  **/
  @RequestMapping("getAddressById")
  @ResponseBody
  public List<AddressBean> getAddressById(){
      return movieApi.getAddressById();
  }
  /*
  * @Author: xz
  * @Description: 查询影厅
  * @Date: 2021/5/30 21:22
  * @Param:
  * @Return:
  **/
  @RequestMapping("getHall")
  @ResponseBody
  public List<MovieHallBean> getHall(){
      return movieApi.getHall();
  }

    @RequestMapping("saveOrder")
    public String saveOrder(OrderBean order, HttpSession session, Model model){
        model.addAttribute("stu",1);
        movieApi.saveOrder(order);
        return "myMessage";
    }
}
